/**
 * Created by Cheney on 2017/8/11.
 */


function _compare(a, b) {
  if( isNaN(a) ){
    a = 0 ;
  }
  if( isNaN(b) ){
    b = 0 ;
  }
  
  if( a > b ){
    return 1;
  }
  if( a < b ){
    return -1;
  }
  return 0;
}

module.exports = {
  compare : function (a, b) {
    var aa = a.split(".");
    var ab = b.split(".");
  
    var ret = _compare( parseInt(aa[0]) , parseInt(ab[0]))
    if( 0 != ret ){
      return ret;
    }
    ret = _compare( parseInt(aa[1]) , parseInt(ab[1]))
    if( 0 != ret ){
      return ret;
    }
    return _compare( parseInt(aa[2]) , parseInt(ab[2]))
  }
}
